import { reactive, computed, toRefs, ref } from 'vue';
// import heartbeat from '@/hooks/deviceHeartbeat';
import { getPriceTagData } from '@/api/device';
import { Pagination, PaginationQuery } from '@/types/table';
import { modelData, childQuery, merchantType } from '@/types/table';
import { TableState, CheckAble } from '@/types/table';

const tableQuery: PaginationQuery = reactive({
    page: 0,
    size: 9,
    sort: 'id,desc',
    typeCode: '',
});

// 角色信息
const state: TableState & CheckAble = reactive({
    dataSource: [],
    selectedRow: {},
    selectedRowKeys: [],
    visible: false,
    loading: false,
    pagination: {
        total: 0,
        current: computed(() => tableQuery.page + 1),
    },
});

// 获取table数据
const iniListData = async (tableQuery: PaginationQuery) => {
    state.loading = true;
    const { content, totalElements } = await getPriceTagData(tableQuery);
    console.log(content);
    state.loading = false;
    state.dataSource = content;
    state.pagination.total = totalElements;
};

export default {
    tableQuery,
    iniListData,
    ...toRefs(state),
};
